#include "string.h"
using namespace ykh;


void TestString1()
{
	ykh::string s1;
	ykh::string s2("hello world");

	ykh::string s3(s2);
	s1 = s2;

	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
	cout << s3.c_str() << endl;
}

void TestString2()
{
	ykh::string s1("hello world");
	ykh::string::iterator it = s1.begin();
	while (it < s1.end())
	{
		cout << *it << " ";
		++it;
	}
	cout << endl;
}

void TestString3()
{
	ykh::string s1 = "hello world";
	ykh::string s2(s1);

	cout << (s1 > s2) << endl;
	cout << (s1 == s2) << endl;
	cout << (s1 < s2) << endl;
}

void TestString4()
{
	ykh::string s1 = "hello";
	s1.append("xxxx");
	s1.push_back('c');
	cout << s1.c_str() << endl;

	s1 += ' ';
	s1 += "world";
	cout << s1.c_str() << endl;
}

void TestString5()
{
	ykh::string s1 = "hello";
	s1.insert(5, 'x');
	s1.insert(6, "world");
	cout << s1.c_str() << endl;
	
	s1.erase(4, 2);
	cout << s1.c_str() << endl;
	s1.erase(6,10);
	cout << s1.c_str() << endl;
	s1.erase(2);
	cout << s1.c_str() << endl;
}

void TestString6()
{
	ykh::string s1 = "hello";
	ykh::string s2 = "world";
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;

	swap(s1, s2);
	cout << s1.c_str() << endl;
	cout << s2.c_str() << endl;
}

void TestString7()
{
	ykh::string s1 = "hello";
	cout << s1.find('l') << endl;

	ykh::string s2 = "0123456789";
	cout << s2.find("456") << endl;
}

void TestString8()
{
	ykh::string s1 = "hello world";
	cout << s1 << endl;

	ykh::string s2;
	cin >> s2;
	cout << s2 << endl;
}

int main()
{
	//TestString1();
	//TestString2();
	//TestString3();
	//TestString4();
	//TestString5();
	//TestString6();
	//TestString7();
	TestString8();

	return 0;
}